package kr.hkit.powerjava.chapter26;

import java.sql.Connection;
import java.util.Scanner;

import kr.hkit.powerjava.chapter26.common.ConnectionFactory;
import kr.hkit.powerjava.chapter26.common.DbUtil;
import kr.hkit.powerjava.chapter26.dto.Department;
import kr.hkit.powerjava.chapter26.dto.Employee;
import kr.hkit.powerjava.chapter26.service.AbsService;
import kr.hkit.powerjava.chapter26.service.DepartmentService;
import kr.hkit.powerjava.chapter26.service.EmployeeService;

public class TestMain {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Connection connection = ConnectionFactory.getConnection();

		int res;

		do {
			System.out.println("1. 사원관리 2. 부서관리 3. 종료");
			switch (res = sc.nextInt()) {
				case 1:
					AbsService<Employee> empSvc = new EmployeeService(sc,
							connection);
					empSvc.prnMenu();
					break;
				case 2:
					AbsService<Department> deptSvc = new DepartmentService(sc,
							connection);
					deptSvc.prnMenu();
					break;
				default:
					DbUtil.close(connection);
					res = 3;
					break;
			}
		} while(res != 3);
	}
}
